"""

"""
from __future__ import generators
from posnet_tcp_client import posnet_ping,posnet_add_handle 

def read_file_txt(input):
	f = file(input,"r")
	line = f.readline()
	while len(line) > 0:
		if len(line[:-1].strip()) > 0:
			sp = line[:-1].split(" ")
			yield sp
		line = f.readline()
	f.close()

def read_file_pkl(input):
	f = file(input,"rb")
	import cPickle
	point_number = cPickle.load(f)
	for point_i in  range(point_number):
		yield cPickle.load(f)
	f.close()

def read_file(input):
	if input.lower().endswith(".pkl"):
		for x in read_file_pkl(input): yield x
	else:
		for x in read_file_txt(input): yield x

if __name__ == "__main__":
	import sys
	host = sys.argv[1] # server address
	port = int(sys.argv[2]) # server port
	
	Poset = posnet_ping( (host,port))
	n = 0	
	for point in read_file(sys.argv[3]):	
		posnet_add_handle( (host,port), point,"")
		n +=1

